<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1200, initial-scale=1.0">
    <title>Document</title>
    <style>
        .p1 {
            visibility: hidden;
        }
    </style>
</head>
<body>
    <ul>
        <li>Java</li>
        <li>JavaScript</li>
    </ul>
    <input type="text" id="txtItem" />
    <button id="btnAdd">+</button>
    <button id="btnDel">-</button>
    <script>
        const oList = document.querySelector('ul')

        document.querySelector('#btnAdd').addEventListener('click',() => {
            let strItem = document.querySelector("#txtItem").value
            let oE = document.createElement('li')
            oE.textContent = strItem
            oList.appendChild(oE)
            document.querySelector("#txtItem").value = ''
            if (oList.childElementCount > 0) {
                document.querySelector('#btnDel').classList.remove('p1')
            }
        })

        document.querySelector('#btnDel').addEventListener('click',() => {
            oList.removeChild(oList.lastElementChild)
            if (oList.childElementCount == 0) {
                document.querySelector('#btnDel').classList.toggle('p1')
            }
        })
    </script>
</body>
</html>